﻿
@{
    ViewBag.Title = "用户登录";
    Layout = "~/Views/Home/_HomeLayout.cshtml";
}
    <link href="~/bootstrapvalidator-master/dist/css/bootstrapValidator.min.css" rel="stylesheet" />
    <script src="~/bootstrapvalidator-master/dist/js/bootstrapValidator.min.js"></script>

    @using (Html.BeginForm("UsersLogin", "User", FormMethod.Post, new { @class = "form-horizontal" }))
    {
        <div class="container" ui-sortable>
            <div class="row">
                <div class="col-lg-8 col-lg-offset-2">
                    <div class="page-header">
                        <h2>用户登录</h2>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-3 control-label">用户名</label>
                        <div class="col-lg-5">
                            <input type="text" class="form-control" name="username" placeholder = "用户名" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-3 control-label">密  码</label>
                        <div class="col-lg-5">
                            <input type="password" class="form-control" name="password" placeholder = "密码"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-4" style="margin-left: 125px">
                            <input class="form-control" id="IMGTXT" name="IMGTXT" type="text" placeholder="验证码" onblur="if(this.value==''){this.value='验证码:'}" onclick="if(this.value=='验证码:'){this.value='';}" value="验证码:" style="width:120px;margin-left:70px">
                        </div>
                        <div class="col-lg-4" style="margin-left: -60px">
                            <img src="/User/YanZhengMa" id="IMG" name="IMG" width="120" height="36" style="cursor:pointer;" title="点击换一张" onclick="CodeImg('IMG')"> <a onclick="CodeImg('IMG')">看不清，换一张</a>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-3"  style="margin-left: 200px">
                            <button type="submit" class="btn btn-primary">登录</button>
                        </div>
                        <div class="col-lg-3">
                            <a href="UsersReg" class="btn btn-link">注册</a>
                        </div>
                    </div>
                    <div class="form-group" style="color:red">
                        @ViewBag.TS
                    </div>
                    </div>
            </div>
        </div>
    }
    <script type="text/javascript">
        function CodeImg(ImgObj) {
            var img = new Date();
            var ImG = document.getElementById(ImgObj);
            ImG.src = "/User/YanZhengMa?" + img.getMilliseconds();
        }
        $(document).ready(function() {
            $('#defaultForm')
                .bootstrapValidator({
                message: 'This value is not valid',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    username: {
                        message: 'The username is not valid',
                        validators: {
                            notEmpty: {
                                message: '用户名不能为空'
                            },
                            stringLength: {
                                min: 6,
                                max: 30,
                                message: '用户名字必须基于6-10之间'
                            },
                            regexp: {
                                regexp: /^[a-zA-Z0-9_\.]+$/,
                                message: '用户名只能包含字母，数字，点和下划线'
                            }
                        }
                    },
                    password: {
                        validators: {
                            notEmpty: {
                                message: '密码是必需的，不能为空'
                            }
                        }
                    }
                }
            });
        });
        </script>
